﻿
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using ThoughtWorks.QRCode.Codec;

namespace generateQR
{
    public partial class Form1 : Form
    {
        string[] args = null;
        public Form1(string[] args)
        {
            InitializeComponent();
            this.args = args;
            this.Location = MousePosition;
            
            //创建二维码生成类
            QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
            //设置编码模式
            qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
            //设置编码测量度
            qrCodeEncoder.QRCodeScale = 10;
            //设置编码版本
            qrCodeEncoder.QRCodeVersion = 0;
            //设置编码错误纠正
            qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
            //生成二维码图片            
            if (args[0] == "-s" && args[1] != "")
            {
                this.BackgroundImage = qrCodeEncoder.Encode(args[1], System.Text.Encoding.UTF8);
            }

            //半透明效果
            //this.FormBorderStyle = FormBorderStyle.None;
            //this.BackColor = Color.White;
            //this.TransparencyKey = this.BackColor;

            new Thread(delegate ()
            {
                Thread.Sleep(11111);

                this.Invoke(new MethodInvoker(delegate ()
                {
                    this.Close();
                }));

            }).Start();
        }
        public Form1()
        {
            InitializeComponent();
            //MessageBox.Show("param is none");
            //this.Close();
        }

        private void Form1_Click(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }
    }
}
